home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWBinaryTree - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss typedef RWBinaryTree SortedCollection; // Smalltalk typedef. #include <rw/bintree.h> RWBinaryTree bt; DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee represents a group of ordered elements, internally sorted by the ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))) function. Duplicates are allowed. An object stored by an RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee must inherit abstract base class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Polymorphic PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RWBinaryTree(); Construct an empty sorted collection. RWBinaryTree(const RWBinaryTree& t); Copy constructor. Constructs a shallow copy from tttt. Member function bbbbaaaallllaaaannnncccceeee(((()))) (see below) is called before returning. virtual ~RWBinaryTree(); Redefined from RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Calls cccclllleeeeaaaarrrr(((()))). PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss void ooooppppeeeerrrraaaattttoooorrrr====(const RWBinaryTree& bt); Sets self to a shallow copy of bbbbtttt. void ooooppppeeeerrrraaaattttoooorrrr++++====(const RWCollection ct); Inserts each element of ....cccctttt into self. Note that using this operator to insert an already-sorted collection will result in creating a very PPPPaaaaggggeeee 1111 RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) unbalanced tree, possibly to the point of stack overflow. RWBoolean ooooppppeeeerrrraaaattttoooorrrr<<<<====(const RWBinaryTree& bt) const; Returns TTTTRRRRUUUUEEEE if self is a subset of the collection bbbbtttt. That is, every item in self must compare equal to a unique item in bbbbtttt. RWBoolean ooooppppeeeerrrraaaattttoooorrrr========(const RWBinaryTree& bt) const; Returns TTTTRRRRUUUUEEEE if self and bbbbtttt are equivalent. That is, they must have the same number of items and every item in self must compare equal to a unique item in bbbbtttt. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss virtual void aaaappppppppllllyyyy(RWapplyCollectable ap, void*); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn to apply the user-supplied function pointed to by aaaapppp to each member of the collection, in order, from smallest to largest. This supplied function should not do anything to the items that could change the ordering of the collection. void bbbbaaaallllaaaannnncccceeee(); Special function to balance the tree. In a perfectly balanced binary tree with no duplicate elements, the number of nodes from the root to any external (leaf) node differs by at most one node. Since this collection allows duplicate elements, a perfectly balanced tree is not always possible. Preserves the order of duplicate elements. virtual RWspace bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void cccclllleeeeaaaarrrr(); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); PPPPaaaaggggeeee 2222 RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual int ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable* a) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual RWBoolean ccccoooonnnnttttaaaaiiiinnnnssss(const RWCollectable* target) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual size_t eeeennnnttttrrrriiiieeeessss() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual RWCollectable* ffffiiiinnnndddd(const RWCollectable* target) const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Returns the first item that compares equal to the item pointed to by ttttaaaarrrrggggeeeetttt, or nnnniiiillll if no item was found. virtual unsigned hhhhaaaasssshhhh() const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. unsigned hhhheeeeiiiigggghhhhtttt() const; Returns the number of nodes between the root node and the farthest leaf. A RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee with one entry will have a height of 1. Note that the entire tree is traversed to discover this value. virtual RWCollectable* iiiinnnnsssseeeerrrrtttt(RWCollectable* c); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Inserts the item cccc into the collection and returns it. Returns nnnniiiillll if the insertion was unsuccessful. The item cccc is inserted according to the value returned by ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))). iiiinnnnsssseeeerrrrtttt(((()))) does not automatically balance the RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee.... Be careful not to iiiinnnnsssseeeerrrrtttt(((()))) a long sequence of sorted items without calling bbbbaaaallllaaaannnncccceeee(((()))) since the result will be very unbalanced (and therefore inefficient). PPPPaaaaggggeeee 3333 RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) virtual RWClassID iiiissssAAAA() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee to return ________RRRRWWWWBBBBIIIINNNNAAAARRRRYYYYTTTTRRRREEEEEEEE. virtual RWBoolean iiiissssEEEEmmmmppppttttyyyy() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual RWBoolean iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* a) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual size_t ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const RWCollectable* target) const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Returns the number of items that compare equal to the item pointed to by ttttaaaarrrrggggeeeetttt. virtual RWCollectable* rrrreeeemmmmoooovvvveeee(const RWCollectable* target); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Removes the first item that compares equal to the object pointed to by ttttaaaarrrrggggeeeetttt and returns it. Returns nnnniiiillll if no item was found. virtual void rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(const RWCollectable* target); Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&); virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&); Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&) const; virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&) const; PPPPaaaaggggeeee 4444 RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee((((3333CCCC++++++++)))) Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn to store objects by level, rather than in order. This results in the tree maintaining its morphology. RWStringID ssssttttrrrriiiinnnnggggIIIIDDDD(); (acts virtual) Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. PPPPaaaaggggeeee 5555